﻿<!doctype html>
<head>
    <meta charset="utf-8" />
</head>
<body>
    <div>可打开浏览器控制台查看结果</div>
    <script src="https://apps.bdimg.com/libs/jquery/1.9.1/jquery.min.js"></script>
    <script src="./md5.js"></script>
    <script type="text/javascript">
        var appid = '20190911000333715';
        var key = 'U7IIBJUTZoNKkeMbRwud';
        var salt = (new Date).getTime();
        var query = 'apple';
        // 多个query可以用\n连接  如 query='apple\norange\nbanana\npear'
        var from = 'en';
        var to = 'zh';
        var str1 = appid + query + salt + key;
        var sign = MD5(str1);
        $.ajax({
            url: 'https://api.fanyi.baidu.com/api/trans/vip/translate',
            type: 'get',
            dataType: 'jsonp',
            data: {
                q: query,
                appid: appid,
                salt: salt,
                from: from,
                to: to,
                sign: sign
            },
            success: function (data) {
                console.log(data);
            }
        });

    </script>
</body>